﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Hadlow.Jobvertizer.Common
{
    public static class ExtensionMethods
    {
        public delegate void Func<T>(T item);

        public static void Each<T>(this IEnumerable<T> items, Func<T> function)
        {
            foreach (T item in items)
            {
                function(item);
            }
        }

        public static bool Exists<T>(this IEnumerable<T> items, Func<T, bool> function)
        {
            foreach (T item in items)
            {
                if (function(item)) return true;
            }
            return false;
        }
    }
}
